using System;

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;


namespace $projectname$
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        { 
            services
                .AddMtp(options => options.UseServiceFactory(Utils.InjectionFactory.AddFactory).UseMicroCenter())
                .AddUtilsDefault()
                .AddMicroDb()
                .AddApiConfig();
#if DEBUG
            services.AddSwaggerExt();
#endif
        }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
#if DEBUG
                app.UseSwagger();
                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "$projectname$ V1");
                    c.RoutePrefix = "";
                });
#endif
            }
            else
            {
                //app.UseCodeFirst(SharedTypes.GetTypes());
            }

            // app.UseJob();
            // app.UseCors();
            app.UseApiConfig();
        }
    }
}
